package com.ds.lens.flink.monitor.common;

import com.google.gson.Gson;
import com.ds.lens.flink.monitor.MonitorJobContext;
import lombok.extern.slf4j.Slf4j;
import org.elasticsearch.common.util.CollectionUtils;

@Slf4j
public class LogUtils {
    public static void debug(String message, Object... args) {
        boolean isDebug = MonitorJobContext.getInstance().isPrintDebug();
        if (isDebug) {
            if (!CollectionUtils.isEmpty(args)) {
                Gson gson = MonitorJobContext.getInstance().getGson();
                String[] strArr = new String[args.length];
                for (int i = 0; i < args.length; i++) {
                    strArr[i] = gson.toJson(args[i]);
                }
                log.info(message, strArr);
            } else {
                log.info(message);
            }
        }
    }
}
